<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<sfa:mainTitle></sfa:mainTitle>
		<%@ include file="../../common/meta.jsp"%>


		<style type="text/css">
* {
	margin: 0;
	padding: 0;
}

.tc_box {
	width: 400px;
	height: 200px;
	border: 2px solid red;
	position: absolute;
	z-index: 2000;
	background: #FFC;
	display: none;
}

.sp_box {
	width: 100%;
	position: absolute;
	z-index: 1000;
	background: #000;
	top: 0;
	left: 0;
	display: none;
}
</style>

		<style>
.main .formdiv {
	width: 400px;
}
</style>
		<script type="text/javascript">
		
		

jQuery.validator.addMethod("loginname", function(value, element) {   
    var tel = /^[a-zA-Z][a-zA-Z0-9_]{4,16}$/;
    return this.optional(element) || (tel.test(value));
}, "");

$(function() {
	
	$("#clear").click(function(){
		$(".inputbox").val("");
	});
	var addForm=$("#addUserForm").validate( {
	 
		rules : {
			//loginName : {
				//required : true,
				//rangelength:[5,16],
				//loginname:true
			//},
			userPassword : {
				required : true,
				rangelength: [7,14],
				loginname:true
			},
			userPassword2 : {
				required : true,
				equalTo:"#userPassword"
			},
			userName : {
				required : true
			},
			email : {
				required : true,
				rangelength:[5,16]
			},
			contactMobile : {
				required : true
				
			}
			
		},
		 messages:{
                //loginName:{required:"",rangelength:"",loginname:""},
                userPassword:{required:"",rangelength:"",loginname:""},
                userPassword2:{required:"",rangelength:"",equalTo:""},
                userName:{required:""},
                email:{required:"",email:""},
                focusInvalid: false,   
 				onkeyup: false //获得焦点时不验证
 				}
	});
	
	$("#submit").click(function(){
			if(addForm.form())
			{
			 $("#addUserForm").ajaxSubmit(function(result) {
			 var json =  eval(result);
					var msg=json.msg;
					 
					if (json.result==true) {
						if(json.flag==true)
						{
					 	art.dialog( {
					icon : 'success',
					lock : true,
					resize : false,
					title : "添加成功",
					content : msg
						});
						location.href='${path}/manage/backusers/index/getusers';
						}else
						{
							art.dialog( {
					icon : 'error',
					lock : true,
					resize : false,
					title : "添加失败",
					content : msg
					});
						}
						 
					} else {
					 
						 $(".mail").html(json.mail);
					}
			 
				});
				 
				}
				});


});
</script>
	</head>



	<body id="master">

		<sfa:mainHeader></sfa:mainHeader>
		<!--右边-->
            <div class="webpart3 contentarea">
                <div class="webpart-head">
                    <div class="webpart-head-item">
                        新增用户<font color="red"><c:out value="${add}"></c:out> </font>
                        
                        <div class="tools-btn">
                             
                            &nbsp;&nbsp;<a href="javascript:" onclick="javascript: history.back();"><span>
                                <img src="${path}/statics/images/Redo.gif" style="margin-right: 4px; margin-bottom: -3px;" />返回</span></a></div>
                    </div>
                </div>
                <div class="webpart-main">
                    <div class="webpart-main-item" style="padding: 30px;">
                        <div class="d_formitem">
                        <form id="addUserForm"
					action="${pageContext.request.contextPath }/manage/backusers/index/add"
					method="post">
                            <table cellspacing="0" cellpadding="0" class="formitem">
                                <tr align="left">
                                    <td style="width: 60px;">
                                        创建人：
                                    </td>
                                    <td align="left">
                                        ${user.userName}(${user.loginName})
									<input type="hidden" class="inputbox" id="userAgentId"
										name="userAgentId">
                                    </td>
                                </tr>
                                <tr align="left">
                                    <td>
                                        电子邮件:
                                    </td>
                                    <td>
                                       <input type="text" class="input-txt" style="width: 40%;" id="loginName" name="loginName" value="${saleUser.loginName}"/>
									<b>@hkfs.cn</b><!-- <font color="red">*</font>长度在5到16位 --><font color="red" class="mail">${mail}</font>
                                    </td>
                                </tr>
                                <tr align="left">
                                    <td>
                                       所属机构:
                                    </td>
                                    <td>
                                        <select name="branchId" class="input-txt" style="width: 30%;"> 
										<c:forEach var="branch" items="${branchs}">
										<option value="${branch.branchId}">
											${branch.branchName}
										</option>
										</c:forEach>
									</select>
                                    </td>
                                </tr>
                                 
                                
                            </table>
                           
                            <div style="margin: 15px;">
                            <input name="submit" type="button" id="submit" tabindex="5"
										class="linkbtn2" value="提交">
									<input name="clear" type="reset" id="clear" tabindex="5"
										class="linkbtn2" value="清空">
                                 
                            </div>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="webpart-foot">
                    <div class="webpart-foot-item">
                    </div>
                </div>
            </div>
		<sfa:mainFooter></sfa:mainFooter>
	</body>
</html>


